﻿using System.Collections.Generic;
using System.IO;
using Domain.UserManagenent;
using Services;
using Domain.Entities;
using Domain.Repositories;

namespace Logic
{
    public class ResultService:IResultService
    {
        
        IQuizRepository QuizRepository;
        IExporter resultExporter;
        public ResultService(IQuizRepository QuizRepository, IExporter resultExporter)
        {
            this.QuizRepository = QuizRepository;
            this.resultExporter = resultExporter;
        }

        public Quiz GetChapterResult(Chapter chapter, User user)
        {
            return QuizRepository.GetChapterResults(chapter, user);
        }
        public IEnumerable<Quiz> GetTopicResult(Topic topic, User user)
        {
            return QuizRepository.GetTopicResults(topic, user);
        }
        public IEnumerable<Quiz> GetCourseResult(Course course, User user)
        {
            return QuizRepository.GetCourseResults(course, user);
        }
        public IEnumerable<Quiz> GetSubjectedQuizes(User user)
        {
            return QuizRepository.GetSubjectedQuizes(user);
        }

        public Stream Export()
        {
            return resultExporter.Export(QuizRepository.GetAll());
        }
    }
}
